<template>
	<view>
		<view class="" style="padding-top: 20rpx;">
			<view class="content">
				<view class="weixinqinabao border-bottom" @tap="qumeixun">
					<view class="weixinqinabao-title">微信钱包</view>
					<view class="wexin-tixing">提现即时到账</view>
					<view class="tobing">{{wxName}}</view>
					<image src="../../static/image/qianjin.png" mode="" class="qianjin" ></image>
				</view>
				<!-- <view class="weixinqinabao" @tap="$util.toUrl('./zhifupwd')">
					<view class="weixinqinabao-title">提现密码</view>
					<view class="tobing">去绑定</view>
					<image src="../../static/image/qianjin.png" mode="" class="qianjin"></image>
				</view> -->
			</view>
		</view>
		<u-toast ref="uToast"></u-toast>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				wxName:"去绑定"
			}
		},
		onLoad:function(paramed){
			var that = this;
			var userInfo = uni.getStorageSync("userInfo");
			if(userInfo.wx_name!=undefined && userInfo.wx_name != null && userInfo.wx_name != ''){
				that.wxName = userInfo.wx_name;
			}
			
			that.$util.nuiAjax(that.$jiekou.updateUser,{id:that.uid,wxName:"",openId:""},function(res){
				if(res.result == 'true'){
					that.wxName = null;
					var userInfo = uni.getStorageSync("userInfo");
					userInfo.wx_name = "";
					userInfo.wx_open_id = "";
					uni.setStorageSync("userInfo",userInfo);
					uni.$emit('wxBing',{wxName:"去绑定"});
				}
				
			});
			
			uni.$on('wxBing',function(data){
			        that.wxName = data.wxName;
			 })
		},
		methods: {
			qumeixun(){
				
				if(plus.runtime.isApplicationExist({pname:'com.tencent.mm',action:'weixin://'})){
					console.log("微信应用已安装");
					this.$util.toUrl('./bingwx');
				}else{
					this.$refs.uToast.show({
						title: "微信应用未安装，请先安装微信",
						duration:2000
					});
					console.log("微信应用未安装");
				}
			}
		}
	}
</script>

<style lang="scss">
	$paddingtop:30rpx;
	.tobing{
		// height:40rpx;
		font-size:28rpx;
		font-weight:400;
		color:rgba(138,139,144,1);
		line-height:40rpx;
		padding-top: 30rpx;
		flex: 1;
		text-align: right;
		padding-right: 22rpx;
		
	}
	.border-bottom{
		border-bottom: 1rpx #EFEFEF solid;
	}
	.wexin-tixing{
		// width: 170rpx;
		height:44rpx;
		text-align: center;
		background:rgba(7,193,96,1);
		border-radius:28rpx;
		font-size:24rpx;
		font-weight:400;
		color:$uni-text-color-inverse;
		line-height:34rpx;
		padding: 10rpx 20rpx 0 20rpx;
		margin-top: 22rpx;
		margin-left: 16rpx;
	}
	
	.weixinqinabao-title{
		padding-top: $paddingtop;
		padding-bottom: $paddingtop;
		
		// height:40rpx;
		font-size:28rpx;
		font-weight:400;
		line-height:40rpx;
	}

	.weixinqinabao {
		display: flex;
		flex-direction: row;
		
	}

	page {
		background-color: $page-bg-color;
	}

	.content {
		box-shadow: 0px 8rpx 16rpx 0px rgba(246, 247, 248, 1);
		background-color: #FFFFFF;
		margin-bottom: 80rpx;
		padding-left: $paddingtop;
	}

	.qianjin {
		width: 10rpx;
		height: 20rpx;
		margin-top: 40rpx;
		margin-right: 20rpx;
	}
</style>
